﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GameDataTempshitEditor
{
    public partial class ErrorBox : Form
    {
        private bool _CenterAroundCursor;

        public ErrorBox()
        {
            InitializeComponent();

            this.Load += ErrorBox_Load;
        }

        void ErrorBox_Load(object sender, EventArgs e)
        {
            if (_CenterAroundCursor)
            {
                int x = Math.Max(0, Math.Min(Cursor.Position.X - (Width / 2), SystemInformation.VirtualScreen.Width - Width));
                int y = Math.Max(0, Math.Min(Cursor.Position.Y - (Height / 2), SystemInformation.VirtualScreen.Height - Height));
                SetDesktopLocation(x, y);
            }
        }

        public static void ShowError(string message, bool centerCursor = true)
        {
            ErrorBox e = new ErrorBox();
            e._CenterAroundCursor = centerCursor;
            e.textBox1.Text = message;
            e.ShowDialog();
        }

        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            e.Handled = true;
            e.SuppressKeyPress = true;
        }
    }
}
